package cn.wolfcode.service.impl;

import cn.wolfcode.domain.LogManage;
import cn.wolfcode.mapper.LogManageMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ILogManageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogManageServiceImpl implements ILogManageService {

    @Autowired
    private LogManageMapper logManageMapper;


    @Override
    public void save(LogManage logManage) {
        logManageMapper.insert(logManage);
    }

    @Override
    public void delete(Long id) {
        logManageMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(LogManage logManage) {
        logManageMapper.updateByPrimaryKey(logManage);
    }

    @Override
    public LogManage get(Long id) {
        return logManageMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<LogManage> listAll() {
        return logManageMapper.selectAll();
    }

    @Override
    public PageInfo<LogManage> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<LogManage> logManages = logManageMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<LogManage>(logManages);
    }
}
